package com.imot.controller;

import com.imot.pojo.dto.AddExperimentDataDto;
import com.imot.pojo.entity.ExperimentFiles;
import com.imot.response.Result;
import com.imot.service.ExperimentDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * ClassName: ExperimentDataController
 * Description:
 * date: 2023/11/30 9:49
 *
 * @author imot-jiah.wang
 */
@Api(tags = "试验数据控制器")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/experimentData")
public class ExperimentDataController {
    private final ExperimentDataService experimentDataService;

    @ApiOperation("获取最上方状态栏数据")
    @GetMapping("/getStatusbar")
    public Result getStatusbar(){
        Result result = experimentDataService.getStatusbar();
        return result;
    }

    @ApiOperation("新增试验数据")
    @PostMapping("/addExperimentData")
    public Result addExperimentData(@ModelAttribute AddExperimentDataDto addExperimentDataDto){
        Result result = experimentDataService.addExperimentData(addExperimentDataDto);
        return result;
    }

    @ApiOperation("删除试验数据")
    @GetMapping("/deleteExperimentData")
    public Result deleteExperimentData(Integer id){
        Result result = experimentDataService.deleteExperimentData(id);
        return result;
    }

//    @ApiOperation("修改试验数据")
    @PutMapping("/updateExperimentData")
    public Result updateExperimentData(ExperimentFiles experimentFiles){
        Result result = experimentDataService.updateExperimentData(experimentFiles);
        return result;
    }

    @ApiOperation("查找试验数据")
    @GetMapping("/getExperimentData")
    public Result getExperimentData(@RequestParam(required = false)Integer page,
                                    @RequestParam(required = false)Integer limit,
                                    @RequestParam(required = false)LocalDateTime start,
                                    @RequestParam(required = false)LocalDateTime end,
                                    @RequestParam(required = false)String exceptionType,
                                    @RequestParam(required = false)String exceptionName){
        Result result = experimentDataService.getExperimentData(page,limit,start,end,exceptionType,exceptionName);
        return result;
    }

    @ApiOperation("获取数据详情")
    @GetMapping("/getExperimentDataDetails")
    public Result getExperimentDataDetails(Integer id){
        Result result = experimentDataService.getExperimentDataDetails(id);
        return result;
    }
}

